class Solution:
    def backspaceCompare(self, s: str, t: str) -> bool:
        def f(st):
            stack=[]
            for char in st:
                if char!="#":
                    stack.append(char)
                elif stack:
                    stack.pop()
            # 数组不能直接比较大小 返回字符串
            return ''.join(stack)
        return f(s)==f(t)